//
//  EDHomeTableHeadView.m
//  EDF
//
//  Created by 张庆勇 on 2019/7/5.
//  Copyright © 2019年 张庆勇. All rights reserved.
//

#import "ZDBHomeTableHeadView.h"
#import "ZDBAlwaysTaskVC.h"
@implementation ZDBHomeTableHeadView
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self get_up];
    }
    return self;
    
}
- (void)get_up
{
    [self addSubview:self.scrollView];
    
    [self addSubview:self.noticeview];
    [_noticeview addSubview:self.noticeimageview];
    [_noticeview addSubview:self.advertScrollViewCenter];
    [_noticeview addSubview:self.moreBtn];    
}
/// 代理方法
- (void)advertScrollView:(SGAdvertScrollView *)advertScrollView didSelectedItemAtIndex:(NSInteger)index {
    WeakSelf
    if (self.Advertblock) {
        weakSelf.Advertblock(index);
    }
}
- (HW3DBannerView*)scrollView{
    
    if (!_scrollView) {
        _scrollView =  [HW3DBannerView initWithFrame:CGRectMake(0, 0, UIScreenWidth ,  150) imageSpacing:2 imageWidth:UIScreenWidth - 40];
        _scrollView.placeHolderImage = [UIImage imageNamed:@"bannernoon"]; // 设置占位图片
        _scrollView.backgroundColor = WHITECOLOR;
        _scrollView.curPageControlColor = WHITECOLOR;
        _scrollView.initAlpha = 1; // 设置两边卡片的透明度
        _scrollView.imageRadius = 4; // 设置卡片圆角
        _scrollView.imageHeightPoor = 6; // 设置中间卡片与两边卡片的高度差
        
        WeakSelf
        _scrollView.clickImageBlock = ^(NSInteger currentIndex) { // 点击中间图片的回调
            
            if (weakSelf.BancelsUrlblock) {
                weakSelf.BancelsUrlblock(currentIndex);
            }
            
        };
    }
    return _scrollView;
}


- (UIView *)noticeview
{
    if (!_noticeview) {
        _noticeview = [[UIView alloc] initWithFrame:CGRectMake(6, _scrollView.bottom +15, self.width-12, RealValue_W(92))];
        UIImageView * imageView = [[UIImageView alloc] init];
        imageView.frame = CGRectMake(0, 0, _noticeview.width, _noticeview.height);
        imageView.image = [UIImage imageNamed:@"gonggaobg"];
        [_noticeview addSubview:imageView];
    }
    return _noticeview;
}
- (UIImageView *)noticeimageview
{
    if (!_noticeimageview) {
        _noticeimageview = [[UIImageView alloc] initWithFrame:CGRectMake(15,_noticeview.height/2 - RealValue_W(27)/2, RealValue_W(30), RealValue_W(27))];
        _noticeimageview.image = [UIImage imageNamed:@"inform"];
        UILabel * lable = [[UILabel alloc] initWithFrame:CGRectMake(_noticeimageview.right +5, 0, 36, 16)];
        lable.textColor = MAINCOLOR;
        lable.font = AutoBoldFont(15);
        lable.centerY = _noticeimageview.centerY;
        lable.text = @"公告";
        [_noticeview addSubview:lable];
       
    }
    return _noticeimageview;
}
- (SGAdvertScrollView *)advertScrollViewCenter
{
    if (!_advertScrollViewCenter) {
        _advertScrollViewCenter = [[SGAdvertScrollView alloc] initWithFrame:CGRectMake(_noticeimageview.right + RealValue_W(86), 0, _noticeview.width -100, _noticeview.height)];
        _advertScrollViewCenter.scrollTimeInterval = 2;
        _advertScrollViewCenter.backgroundColor = CLEARCOLOR;
        _advertScrollViewCenter.titleFont = AutoFont(12);
        _advertScrollViewCenter.titleColor = MAINTITLECOLOR;
        _advertScrollViewCenter.delegate = self;
    }
    return _advertScrollViewCenter;
}
- (UIButton *)moreBtn
{
    if (!_moreBtn) {
        _moreBtn = [[UIButton alloc] initWithFrame:CGRectMake(_noticeview.width -50, 0, 50, _noticeview.height)];
        [_moreBtn setImage:[UIImage imageNamed:@"more"] forState:0];
    }
    return _moreBtn;
}
@end
